{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(<class '__main__.D'>, <class '__main__.B'>, <class '__main__.C'>, <class '__main__.A'>, <class 'object'>)\n",
      "D\n",
      "B\n",
      "C\n",
      "A\n"
     ]
    }
   ],
   "source": [
    "class A:\n",
    "    def __init__(self):\n",
    "        print('A')\n",
    "        \n",
    "class B(A):\n",
    "    def __init__(self):\n",
    "        print('B')\n",
    "        super().__init__()\n",
    "\n",
    "class C(A):\n",
    "    def __init__(self):\n",
    "        print('C')\n",
    "        super().__init__()\n",
    "        \n",
    "class D(B, C):\n",
    "    def __init__(self):\n",
    "        print('D')\n",
    "        super(D, self).__init__()\n",
    "        \n",
    "# 既然我们重写B的构造函数，为什么还要去调用super\n",
    "# super 到底执行顺序是什么样的？\n",
    "\n",
    "# 执行父类中的构造函数\n",
    "# from threading import Thread\n",
    "# class MyThread(Thread):\n",
    "#     def __init__(self, name, user):\n",
    "#         self.user = user\n",
    "#         super().__init__(name, name)\n",
    "\n",
    "if __name__ == '__main__':\n",
    "    print(D.__mro__)\n",
    "    d = D()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
